<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>用户信息修改</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/layui/css/layui.css"/>
{#    <link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css"/>#}
</head>
<body>
    <div class="layui-tab page-content-wrap">
        <ul class="layui-tab-title">
            <li class="layui-this">修改资料</li>
            <li>修改密码</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form" style="width: 90%;padding-top: 20px;">
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" required lay-verify="required" placeholder="请输入用户名" autocomplete="off" class="layui-input" value="{{ userInfo.name }}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">电话：</label>
                        <div class="layui-input-block">
                            <input type="text" name="phone" required lay-verify="required" placeholder="请输入电话" autocomplete="off" class="layui-input" value="{{ userInfo.phone }}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">邮箱：</label>
                        <div class="layui-input-block">
                            <input type="text" name="email" required lay-verify="required" placeholder="请输入邮箱" autocomplete="off" class="layui-input" value="{{ userInfo.email }}">
                        </div>
                    </div>
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">备注：</label>
                        <div class="layui-input-block">
                            <textarea name="remark" placeholder="请输入备注" class="layui-textarea">{{ userInfo.remark }}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="userInfo">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form" style="width: 90%;padding-top: 20px;">
                    <div class="layui-form-item">
                        <label class="layui-form-label">用户名：</label>
                        <div class="layui-input-block">
                            <input type="text" name="username" disabled autocomplete="off" class="layui-input layui-disabled" value="{{ userInfo.name }}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">旧密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="oldPassword" required lay-verify="required" placeholder="请输入旧密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">新密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="newPassword" required lay-verify="required" placeholder="请输入新密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">重复密码：</label>
                        <div class="layui-input-block">
                            <input type="password" name="confirmPassword" required lay-verify="required" placeholder="请再次输入新密码" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="userPassword">立即提交</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
    <script src="../../static/admin/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script>
        //Demo
        layui.use(['form', 'element'], function(){
            var form = layui.form;
            var element = layui.element;
            var $ = layui.jquery;
            form.render();
            //监听信息提交
            form.on('submit(userInfo)', function(data){
                layer.msg(JSON.stringify(data.field));
                $.ajax({
                    url: '/updateUserInfo',
                    data: data.field,
                    dataType: 'json',
                    type: 'post',
                    success: function (res){
                        if(res.code == 200){
                            layer.alert(res.msg);
                        } else {
                            layer.alert(res.msg);
                        }
                    },
                    error: function (a, b, c){
                        layer.alert("系统异常，请联系管理员！");
                    }
                });
                return false;
            });
            //监听密码提交
            form.on('submit(userPassword)', function(data){
                layer.msg(JSON.stringify(data.field));
                $.ajax({
                    url: '/updateUserPassword',
                    data: data.field,
                    dataType: 'json',
                    type: 'post',
                    success: function (res){
                        if(res.code == 200){
                            layer.alert(res.msg);
                        } else {
                            layer.alert(res.msg);
                        }
                    },
                    error: function (a, b, c){
                        layer.alert("系统异常，请联系管理员！");
                    }
                });
                return false;
            });
        });
    </script>
</body>
</html>